package com.yyfax.pay.common.enums;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.commons.lang3.StringUtils;

import com.yyfax.framework.yyfax.BaseEnum;

/**
 * 支付通道枚举
 * 
 * @author jiangmy
 * @date 2017-04-11 10:18:29
 * @since v1.0.0
 */
@SuppressWarnings("serial")
public final class PaymentEnum extends BaseEnum<String> {

	/** 枚举集合 */
	protected static final Map<String, PaymentEnum> values = new HashMap<>();

	public static final String ENUM_KEY = "PAYMENT";

	public static final PaymentEnum LIAN_LIAN = PaymentEnum.build("LIAN_LIAN", "P00001", "连连支付");

	public static final PaymentEnum QUICK_PAY = PaymentEnum.build("QUICK_PAY", "P00002", "快钱支付");

	public static final PaymentEnum FUIOU = PaymentEnum.build("FUIOU", "P00003", "富友支付");

	public static final PaymentEnum MIN_SHENG = PaymentEnum.build("MIN_SHENG", "P00004", "民生支付");

	public static final PaymentEnum BAOFU = PaymentEnum.build("BAOFU", "P00005", "宝付支付");

	public static final PaymentEnum FUIOU_DEPOSIT = PaymentEnum.build("FUIOU_DEPOSIT", "P00007", "富友存管");

	public static final PaymentEnum FIEL_SERVER = PaymentEnum.build("FIEL_SERVER", "P00008", "文件服务");

	public static final PaymentEnum ALL_IN_PAY = PaymentEnum.build("ALL_IN_PAY", "P00009", "通联");

	public static final PaymentEnum FUIOU_PROTOCOL_PAY = PaymentEnum.build("FUIOU_PROTOCOL_PAY", "P00010", "富友协议支付");
	/**
	 * 构造函数
	 */
	private PaymentEnum(String name, String value, String remark) {
		super(name, value, remark);
	}

	public static List<PaymentEnum> values() {
		return new ArrayList<PaymentEnum>(values.values());
	}

	/**
	 * 不存在则添加,存在则更新(用于数据库加载时)
	 * 
	 * @author jiangmy
	 * @date 2016-12-05 19:31:30
	 * @param name
	 * @param value
	 * @param remark
	 * @return
	 */
	public static final PaymentEnum build(String name, String value, String remark) {
		PaymentEnum e = values.get(name);
		if (e == null) {
			e = new PaymentEnum(name, value, remark);
			values.put(name, e);
		} else {
			e.value = value;
			e.remark = remark;
		}
		return e;
	}

	public static final PaymentEnum fromValue(String value) {
		for (PaymentEnum e : values.values()) {
			if (StringUtils.equals(value, e.getValue())) {
				return e;
			}
		}
		return null;
	}
}
